package com.xc58.highreactor.serialize;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.util.Arrays;
import java.util.zip.GZIPOutputStream;

import com.xc58.highreactor.seril.SerialMatcher;

public class Main {
	public static void main(String[] args) throws Exception {
		TestEntity entity = new TestEntity(null, 11, null, '中','国',(short)21, (short)22, 31L, 32L,"123123");
		TestEntity newObj = new TestEntity();
		
		TestEntity test111 = new TestEntity("8888", 111, 112, '呗','嚄',(short)221, (short)222, 331L, 332L,"9999");
		entity.setEntity(test111);
		
		entity.setOarray1(new Object[]{null,1,3,test111});
		
		entity.setIarray(new int[]{3,5,33});
		/*
		byte[] test = Serialize.serialize(entity);
		System.out.println(Arrays.toString(test));

		byte[] b = null;
		try {
			ByteArrayOutputStream bos = new ByteArrayOutputStream();
			GZIPOutputStream gzip = new GZIPOutputStream(bos);
			gzip.write(test);
			gzip.finish();
			gzip.close();
			b = bos.toByteArray();
			bos.close();
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		*/
		System.out.println(Arrays.toString(SerialMatcher.serializer(entity)));
		ByteArrayInputStream input = new ByteArrayInputStream(SerialMatcher.serializer(entity));
		System.out.println(SerialMatcher.deserializer(input));
	}

	public <T> T getTest(T t){
		return t;
	}
}
